import '../../style/home.css'
import React from 'react'
import ReactDOM from 'react-dom'
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Redirect, History, Link, browserHistory } from 'react-router-dom'

class Login extends React.Component {
    constructor(props) {
        super(props)
       this.state = {
            username: "",
            password: ""
       } 
    }
    handleSubmit(event) {
        event.preventDefault()
       /* var data={};
            data.operation = "userManage";
            data.action = "login";
            data.params = {
                username : this.state.username,
                password : this.state.password,
            };
            data = JSON.stringify(data);
            $.ajax({
                url:"http://192.168.1.11/XService/x.api",
                data: data,
                type:"POST",
                dataType: "text",
                async: true,
                success : function(result){
                    
                },
                error : function(xhr, status, err){
                    
                }
            }); */
        return this.props.history.push('/graph/aaaaa')
    }
    handleChange(e) {
            var newState = {};
            this.state[e.target.name] = e.target.value;
            this.setState(this.state)
    }
    render() {
        return (
            <div className="login">
                <div className="welcome"><img src='images/LOGO.png' /></div>
                <form onSubmit={this.handleSubmit.bind(this)} className="login-form">
                    <div className="login-inp">
                        <label>账号</label>
                        <input type="text"name ="username" placeholder="手机/邮箱" value={this.state.username} onChange={this.handleChange.bind(this)}/>
                    </div>
                    <div className="login-inp">
                      <label>密码</label>
                      <input type="password"name="password" placeholder="密码6~20字符" value={this.state.password} onChange={this.handleChange.bind(this)} />                     
                    </div>
                    <div className="login-inp subBtn">
                        <button type="submit">登陆</button>
                    </div>
                  
                </form>

                
            </div>
        )
    }
}

export default compose(
    connect(state =>{console.log(state );return state.login;}),
)(Login);
